package com.hex.ds.hdrs.app.converter;

import com.hex.bigdata.hbda.service.dto.UserDto;
import com.hex.ds.hdrs.app.dto.AppAdminRelationDto;
import com.hex.ds.hdrs.app.dto.AppConfDto;
import com.hex.ds.hdrs.app.po.AppAdminRelationPo;
import com.hex.ds.hdrs.common.utils.BaseUtil;
import com.hex.ds.hdrs.common.utils.HdrsDateUtil;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

/**
 * @Package com.hex.ds.hdrs.app.converter
 * @ClassName IAppAdminRelationConverter
 * @Description 应用与管理员关联业务转换器
 * @Author yu liuyang
 * @Date 2023/4/18 14:08
 * @Version v1.0
 **/
@Mapper(componentModel = "spring", imports = {HdrsDateUtil.class, BaseUtil.class})
public interface IAppAdminRelationConverter {


    /**
     * @Method toAppAdminRelation <br>
     * @Param [appAdminRelationDto] <br>
     * @Return com.hex.ds.hdrs.app.po.AppAdminRelation <br>
     * @Description 将AppAdminRelationDto转换成AppAdminRelation <br>
     * @Author yu liuyang <br>
     * @Date 2023/4/18 14:08 <br>
     * @Version V1.0 <br>
     */
    @Mapping(target = "upTs", expression = "java(HdrsDateUtil.getCurrentTime())")
    AppAdminRelationPo toAppAdminRelation(AppAdminRelationDto appAdminRelationDto);

    /**
     * @Method userDtoToAppAdminRelation <br>
     * @Param [userDto] <br>
     * @Return com.hex.ds.hdrs.app.po.AppAdminRelation <br>
     * @Description 将UserDto转换成AppAdminRelation <br>
     * @Author yu liuyang <br>
     * @Date 2023/4/18 14:09 <br>
     * @Version V1.0 <br>
     */
    @Mapping(target = "adminUserCode", source = "username")
    @Mapping(target = "adminUserName", source = "nickName")
    @Mapping(target = "upTs", expression = "java(HdrsDateUtil.getCurrentTime())")
    AppAdminRelationPo userDtoToAppAdminRelation(UserDto userDto);

    /**
     * @Method toAppAdminRelationDto <br>
     * @Param [appConfDto] <br>
     * @Return com.hex.ds.hdrs.app.dto.AppAdminRelationDto <br>
     * @Description 将AppConfDto转换成AppAdminRelationDto <br>
     * @Author yu liuyang <br>
     * @Date 2023/4/18 14:09 <br>
     * @Version V1.0 <br>
     */
    AppAdminRelationDto toAppAdminRelationDto(AppConfDto appConfDto);

    /**
     * @Method AppCodeAndAdminUserCodeToAppAdminRelationDto <br>
     * @Param [appCode] <br>
     * @Return com.hex.ds.hdrs.app.dto.AppAdminRelationDto <br>
     * @Description 为AppAdminRelationDto设置赋值appCode与adminUserCode属性 <br>
     * @Author yu liuyang <br>
     * @Date 2023/4/18 14:10 <br>
     * @Version V1.0 <br>
     */
    @Mapping(target = "adminUserCode", expression = "java(BaseUtil.getUserId())")
    AppAdminRelationDto AppCodeAndAdminUserCodeToAppAdminRelationDto(String appCode);

}
